package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceSuppliesprice;
import com.ruoyi.service.service.IServiceSuppliespriceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 耗材与价格调整对照Controller
 * 
 * @author ZDL
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/service/suppliesprice")
public class ServiceSuppliespriceController extends BaseController
{
    @Autowired
    private IServiceSuppliespriceService serviceSuppliespriceService;

    /**
     * 查询耗材与价格调整对照列表
     */
    @PreAuthorize("@ss.hasPermi('service:suppliesprice:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceSuppliesprice serviceSuppliesprice)
    {
        startPage();
        List<ServiceSuppliesprice> list = serviceSuppliespriceService.selectServiceSuppliespriceList(serviceSuppliesprice);
        return getDataTable(list);
    }

    /**
     * 导出耗材与价格调整对照列表
     */
    @PreAuthorize("@ss.hasPermi('service:suppliesprice:export')")
    @Log(title = "耗材与价格调整对照", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceSuppliesprice serviceSuppliesprice)
    {
        List<ServiceSuppliesprice> list = serviceSuppliespriceService.selectServiceSuppliespriceList(serviceSuppliesprice);
        ExcelUtil<ServiceSuppliesprice> util = new ExcelUtil<ServiceSuppliesprice>(ServiceSuppliesprice.class);
        util.exportExcel(response, list, "耗材与价格调整对照数据");
    }

    /**
     * 获取耗材与价格调整对照详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:suppliesprice:query')")
    @GetMapping(value = "/{suppliespriceId}")
    public AjaxResult getInfo(@PathVariable("suppliespriceId") Long suppliespriceId)
    {
        return success(serviceSuppliespriceService.selectServiceSuppliespriceBySuppliespriceId(suppliespriceId));
    }

    /**
     * 新增耗材与价格调整对照
     */
    @PreAuthorize("@ss.hasPermi('service:suppliesprice:add')")
    @Log(title = "耗材与价格调整对照", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceSuppliesprice serviceSuppliesprice)
    {
        return toAjax(serviceSuppliespriceService.insertServiceSuppliesprice(serviceSuppliesprice));
    }

    /**
     * 修改耗材与价格调整对照
     */
    @PreAuthorize("@ss.hasPermi('service:suppliesprice:edit')")
    @Log(title = "耗材与价格调整对照", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceSuppliesprice serviceSuppliesprice)
    {
        return toAjax(serviceSuppliespriceService.updateServiceSuppliesprice(serviceSuppliesprice));
    }

    /**
     * 删除耗材与价格调整对照
     */
    @PreAuthorize("@ss.hasPermi('service:suppliesprice:remove')")
    @Log(title = "耗材与价格调整对照", businessType = BusinessType.DELETE)
	@DeleteMapping("/{suppliespriceIds}")
    public AjaxResult remove(@PathVariable Long[] suppliespriceIds)
    {
        return toAjax(serviceSuppliespriceService.deleteServiceSuppliespriceBySuppliespriceIds(suppliespriceIds));
    }
}
